import axios from "axios";
import {useStore} from "../pinia/index.js";

axios.interceptors.request.use(
    (config) => {
        //携带token 令牌
        const store=useStore()
        config.headers.Lctoken = store.token
        return config;
    }, (error) => {
        return Promise.reject(error);
    }
);

const baseurl="http://localhost:8083/api/"

// post请求
const postFile = (url, file) => {
    const formData = new FormData();
    formData.append('file', file);
    return axios.post(baseurl+url,formData, {
        headers: {
            'Content-Type': 'multipart/form-data'  // 提交文件
        }
    }).then(res => res.data);
};
export {
    postFile
}
